package com.beta.platform.rest.config;

import com.beta.platform.rest.interceptor.AddSignetInterceptor;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置类，业务使用时配置 com.beta.signet.interceptor.enable=true 会开启该过滤器
 */
@Configuration
@ConditionalOnProperty(name = "com.beta.signet.interceptor.enable", havingValue = "true", matchIfMissing = false)
@ConditionalOnClass({LoggerFactory.class,WebMvcConfigurer.class})
public class SignetInterceptorAutoConfiguration implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AddSignetInterceptor()).addPathPatterns("/**");
    }

}